//
//  HZPersonageView.m
//  MyDoctor
//
//  Created by 黑眼圈 on 16/5/4.
//  Copyright © 2016年 heiyan. All rights reserved.
//

#import "HZPersonageView.h"

@interface HZPersonageView()

@property(nonatomic,strong)UIImageView*  icon;
@property(nonatomic,strong)UILabel*  nameLabel;
@property(nonatomic,strong)UILabel*  numLabel;

@end

@implementation HZPersonageView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        //设置并添加子控件
        [self setupUI];
    }
    return self;
}

#pragma mark -
#pragma mark    设置并添加子控件
-(void)setupUI{
    
    self.backgroundColor = [UIColor colorWithRed:0/255.0 green:198/255.0 blue:199/255.0 alpha:1];
    
    //添加
    [self addSubview:self.icon];
    [self addSubview:self.nameLabel];
    [self addSubview: self.numLabel];
    
    
    //约束
    [self.icon makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(25);
        make.leading.equalTo(20);
        make.height.equalTo(60);
        make.width.equalTo(60);
    }];

    [self.nameLabel makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(self.icon);
        make.leading.equalTo(self.icon.trailing).offset(15);
    }];
    
    [self.numLabel makeConstraints:^(MASConstraintMaker *make) {
        
        make.bottom.equalTo(self.icon);
        make.leading.equalTo(self.icon.trailing).offset(15);
        
    }];
    
}






#pragma mark -
#pragma mark     懒加载
-(UIImageView *)icon{
    if (!_icon) {
        
        _icon = [[UIImageView alloc]init];
        
        _icon.image = [UIImage imageNamed:@"name"];
    }
    return _icon;
}

-(UILabel *)nameLabel{
    if (!_nameLabel) {
        
        _nameLabel = [[UILabel alloc]init];
        
        _nameLabel.text = @"XXX";
        _nameLabel.textColor = [UIColor whiteColor];
        [_nameLabel sizeToFit];
    }
    return _nameLabel;
}



-(UILabel *)numLabel{
    if (!_numLabel) {
        
        _numLabel = [[UILabel alloc]init];
        
        _numLabel.text = @"1233455678887764534";
        _numLabel.textColor = [UIColor whiteColor];
        _numLabel.font = [UIFont systemFontOfSize:13];
        [_numLabel sizeToFit];
    }
    return _numLabel;
}





@end
